#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int i,n;
    float B,A,x[10],y[10],xsum,xsqsum,ysum,xysum,D;
    xsum=0;
    xsqsum=0;
    ysum=0;
    xysum=0;
    cout<<"Enter the value of n,less than or equal to 10 :\t";
    cin>>n;
    for(i=0;i<n;i++)
    {
        cout<<"Enter the value of x and y\t";
        cin>>x[i]>>y[i];
    }
    for(i=0;i<n;i++)
    {
        xsum=xsum+x[i];
        ysum=ysum+y[i];
        xsqsum=xsqsum+(x[i]*x[i]);
        xysum=xysum+(x[i]*y[i]);
    }
    D=((n*xsqsum)-xsum*xsum);
    if(D==0)
    {
        cout<<"No solution !\n";
    }
    else
    {
        B=(((n*xysum)-xsum*ysum))/D;
        A=((ysum*xsqsum)-(xysum*xsum))/D;
        cout<<endl;
        cout<<"The linear equation is :\t";
        cout<<"y="<<B<<"x+"<<A<<endl<<endl;
        cout<<"The value of A="<<A<<endl<<endl;
        cout<<"The value of B="<<B<<endl<<endl;
    }
    cin.get();
}
